package com.zy.mc_module.wheel.dialog;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import androidx.annotation.LayoutRes;
import androidx.core.content.ContextCompat;

import com.zy.mc_module.R;
import com.zy.mc_module.base.BaseAdapter;
import com.zy.mc_module.wheel.recyclerview.BaseViewHolder;

import java.util.List;

/**
 * Created on 18/11/21
 * 通用Dialog 的列表item
 */
public class CommonDialogAdapter extends BaseAdapter<String> {
    private Context context;
    private List<String> mlists;
    private int type;//0:垂直/1水平
    private boolean isWhite;

    public CommonDialogAdapter(Context context,List<String> lists, int type) {
        super(lists, R.layout.item_commondialog);
        this.context = context;
        this.mlists = lists;
        this.type = type;
    }

    public CommonDialogAdapter(Context context,@LayoutRes int layoutId, List<String> lists, int type, boolean isWhite) {
        super(lists, layoutId);
        this.context = context;
        this.mlists = lists;
        this.type = type;
        this.isWhite = isWhite;
    }

    @Override
    protected void onMyBindViewHolder(BaseViewHolder holder, int position) {
        RelativeLayout relativeLayout = holder.getView(R.id.item_common_relative);
        if (type == 0) {
            ViewGroup.LayoutParams params = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            relativeLayout.setLayoutParams(params);
            //垂直
            holder.setVisible(R.id.item_msg, true);
            holder.setVisible(R.id.item_sharemsg, false);
            holder.setText(R.id.item_msg, mlists.get(position));
        } else if (type == 1) {
            ViewGroup.LayoutParams params = new RelativeLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            relativeLayout.setLayoutParams(params);
            //水平
            holder.setVisible(R.id.item_msg, false);
            holder.setVisible(R.id.item_sharemsg, true);
            holder.setTextColor(R.id.item_sharemsg, ContextCompat.getColor(context,isWhite ? R.color.white : R.color.color_666));
//            if ("微信好友".equals(mlists.get(position))) {
//                holder.setTextD(R.id.item_sharemsg, mlists.get(position), isWhite ? R.drawable.icon_wx_white : R.drawable.weix, 2);
//            } else if ("朋友圈".equals(mlists.get(position))) {
//                holder.setTextD(R.id.item_sharemsg, mlists.get(position), isWhite ? R.drawable.icon_pyq_white : R.drawable.wx_friend, 2);
//            } else if ("QQ".equals(mlists.get(position))) {
//                holder.setTextD(R.id.item_sharemsg, mlists.get(position), isWhite ? R.drawable.icon_qq_white : R.drawable.qq, 2);
//            } else if ("微博".equals(mlists.get(position))) {
//                holder.setTextD(R.id.item_sharemsg, mlists.get(position), R.drawable.weibo, 2);
//            } else if ("分享图片".equals(mlists.get(position))) {
//                holder.setTextD(R.id.item_sharemsg, mlists.get(position), R.drawable.share_picture, 2);
//            } else if ("复制链接".equals(mlists.get(position))) {
//                holder.setTextD(R.id.item_sharemsg, mlists.get(position), R.drawable.share_url, 2);
//            }
        }
    }
}
